﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using HalconDotNet;

namespace TestYsHObject2Bitmap
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            ysHobject2Bitmap=new YsHObject2Bitmap.HObject2Bitmap();
        }


        HObject hoImage;

        YsHObject2Bitmap.HObject2Bitmap ysHobject2Bitmap;  

        private void btnReadImage_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();
            dialog.Filter = "图片文件|*.bmp;*.jpg;*.jpeg;*.tif";
            dialog.Title = "打开文件";
            if (dialog.ShowDialog() == true)
            {
                
               
               
                    HOperatorSet.ReadImage(out hoImage, dialog.FileName);


                image1.Source=    ysHobject2Bitmap.GetBitmapSource(hoImage);



                    if (hoImage != null && hoImage.IsInitialized())
                    {
                        hoImage.Dispose();
                    }

               
            }

        }
    }
}
